"use strict";

module.exports = {
  up: (queryInterface, dataTypes) => {
    /*
      Add altering commands here.
      Return a promise to correctly handle asynchronicity.

      Example:
      return queryInterface.createTable('users', { id: Sequelize.INTEGER });
    */
    return queryInterface.createTable("articles", {
      id: {
        type: dataTypes.INTEGER.UNSIGNED,
        autoIncrement: true,
        primaryKey: true,
      },
      title: {
        // 标题
        type: dataTypes.STRING,
      },
      content: {
        // 内容
        type: dataTypes.STRING,
      },
      views: {
        // 查看次数
        type: dataTypes.INTEGER.UNSIGNED,
      },
      comments: {
        // 评论数
        type: dataTypes.INTEGER.UNSIGNED,
      },
      likes: {
        // 点赞数
        type: dataTypes.INTEGER.UNSIGNED,
      },
      favorites: {
        // 收藏数
        type: dataTypes.INTEGER.UNSIGNED,
      },
      author_id: {
        // 作者ID
        type: dataTypes.INTEGER.UNSIGNED,
      },
      is_lock: {
        // 文章状态 0: 正常 1:锁定
        type: dataTypes.INTEGER.UNSIGNED,
      },
    });
  },

  down: (queryInterface, Sequelize) => {
    /*
      Add reverting commands here.
      Return a promise to correctly handle asynchronicity.

      Example:
      return queryInterface.dropTable('users');
    */
    return queryInterface.dropTable("articles");
  },
};
